use std::env;
pub struct ConfigDto {
    pub query: String,
    pub file_path: String,
    // 是否忽略大小写
    pub ignore_case: bool,
}
impl ConfigDto {
    pub fn build(mut args:impl Iterator<Item = String>
    ) -> Result<ConfigDto, &'static str> {
        //跳过第一个固定参数
        args.next();
        // 使用迭代器消除 clone
        let query = match args.next() {
            Some(arg)=>arg,
            None => return Err("请传递查询参数。")
        };
        let file_path = match args.next() {
            Some(arg)=>arg,
            None => return Err("请传递文件路径参数。")
        };
        Ok(ConfigDto {
            query: query,
            file_path: file_path,
            ignore_case: env::var("IGNORE_CASE").is_ok(),
        })
    }
}
